package com.chb.model.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author: 陈海彬
 * @date: Created in 2023/9/22 12:31
 * @description: 统一响应结果
 * @modified By:
 * @version: 1.0
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result {
    private Integer code;       //响应码：200代表成功;500代表失败
    private String msg;         //响应信息：描述字符串
    private Object data;        //返回的数据

    /**
     * @param data
     * @create by: 陈海彬
     * @description: 查询————成功响应(携带数据)
     * @create time: 2023/9/22 12:33
     */
    public static Result success(Object data) {
        return new Result(200, "success", data);
    }

    /**
     * @create by: 陈海彬
     * @description: 查询————成功响应(不携带数据)
     * @create time: 2023/9/22 12:34
     */
    public static Result success() {
        return new Result(200, "success", null);
    }

    /**
     * @create by: 陈海彬
     * @description: 失败响应(不携带数据)
     * @create time: 2023/9/22 12:34
     */
    public static Result error() {
        return new Result(500, "error", null);
    }
}